home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb / xxx < prev   
Encoding:
Text File  |  1990-11-14  |  16.6 KB  |  828 lines

  1. # 1 "inflow.c"
  2.  
  3. # 1 "/sprite/lib/include/stdio.h" 1
  4.  
  5.  
  6. # 1 "/sprite/lib/include/cfuncproto.h" 1
  7.  
  8.  
  9. typedef char *_VoidPtr;
  10. # 32 "/sprite/lib/include/stdio.h" 2
  11. typedef int *ClientData;
  12.  
  13. typedef struct _file {
  14.     unsigned char *lastAccess;     
  15.     int readCount;         
  16.     int writeCount;         
  17.     unsigned char *buffer;     
  18.     int bufSize;         
  19.     void (*readProc)() ;
  20.                  
  21.     void (*writeProc)() ;
  22.                  
  23.     int (*closeProc)() ;
  24.                  
  25.     ClientData clientData;     
  26.     int status;             
  27.     int flags;             
  28.     struct _file *nextPtr;     
  29. } FILE;
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. extern FILE stdioInFile, stdioOutFile, stdioErrFile;
  39.  
  40.  
  41.  
  42.  
  43.  
  44.         extern  void    clearerr () ;
  45.         extern  int    fclose () ;
  46.         extern  FILE *    fdopen () ;
  47.         extern  int    fflush () ;
  48.         extern  int    fgetc () ;
  49.         extern  char *    fgets () ;
  50.         extern  int    fileno () ;
  51.         extern  FILE *    fopen () ;
  52.         extern  int    fputc () ;
  53.         extern  int    fputs () ;
  54.         extern  int    fread () ;
  55.         extern  FILE *    freopen () ;
  56.         extern  long    fseek () ;
  57.         extern  long    ftell () ;
  58.         extern  int    fwrite () ;
  59.         extern  char *    gets () ;
  60.         extern  int    getw () ;
  61.         extern  void    perror () ;
  62.         extern  FILE *    popen () ;
  63.         extern  int    pclose () ;
  64.         extern  int      remove () ;
  65.         extern  int      rename () ;
  66. # 333 "/sprite/lib/include/stdio.h"
  67.  
  68.         extern  int    printf () ;
  69.         extern  int    fprintf () ;
  70.         extern  int    scanf () ;
  71.         extern  char *    sprintf () ;
  72.         extern  int    sscanf () ;
  73.         extern  int    fscanf () ;
  74.         extern  int    vfprintf () ;
  75.         extern  int    vfscanf () ;
  76.         extern  int    vprintf () ;
  77.         extern  char *    vsprintf () ;
  78.         extern  int    puts () ;
  79.         extern  int    putw () ;
  80.         extern  void    rewind () ;
  81.         extern  void    setbuf () ;
  82.         extern  void    setbuffer () ;
  83.         extern  void    setlinebuf () ;
  84.         extern  int    setvbuf () ;
  85.         extern  FILE *    tmpfile () ;
  86.         extern  char *    tmpnam () ;
  87.         extern  char *    tempnam () ;
  88.         extern  int    ungetc () ;
  89.         extern  void    _cleanup () ;
  90.         extern  void    Stdio_Setup () ;
  91. # 20 "inflow.c" 2
  92. # 1 "dist/defs.h" 1
  93.  
  94. extern char *savestring ();
  95. extern char *concat ();
  96. extern char *xmalloc (), *xrealloc ();
  97. extern int parse_escape ();
  98. extern char *reg_names[];
  99.  
  100. extern int quit_flag;
  101. extern int immediate_quit;
  102.  
  103. enum command_class
  104. {
  105.   no_class = -1, class_run = 0, class_vars, class_stack,
  106.   class_files, class_support, class_info, class_breakpoint,
  107.   class_alias, class_obscure, class_user,
  108. };
  109.  
  110. struct cleanup
  111. {
  112.   struct cleanup *next;
  113.   void (*function) ();
  114.   int arg;
  115. };
  116. extern void do_cleanups ();
  117. extern void discard_cleanups ();
  118. extern struct cleanup *make_cleanup ();
  119. extern struct cleanup *save_cleanups ();
  120. extern void restore_cleanups ();
  121. extern void free_current_contents ();
  122. extern void reinitialize_more_filter ();
  123. extern void fputs_filtered ();
  124. extern void fprintf_filtered ();
  125. extern void printf_filtered ();
  126. extern void print_spaces_filtered ();
  127. extern char *tilde_expand ();
  128.  
  129. struct command_line
  130. {
  131.   struct command_line *next;
  132.   char *line;
  133. };
  134. struct command_line *read_command_lines ();
  135.  
  136. char *current_directory;
  137. # 21 "inflow.c" 2
  138. # 1 "symm.md/param.h" 1
  139.  
  140.  
  141.  
  142. # 1 "dist/m-i386.h" 1
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208. # 352 "dist/m-i386.h"
  209.  
  210. # 394 "dist/m-i386.h"
  211. # 30 "symm.md/param.h" 2
  212. # 22 "inflow.c" 2
  213. # 1 "dist/frame.h" 1
  214.  
  215.  
  216.  
  217. typedef struct frame_info *FRAME;
  218. typedef unsigned int     FRAME_ADDR;
  219.  
  220. struct frame_info
  221.   {
  222.      
  223.     FRAME_ADDR frame;
  224.      
  225.     unsigned int  pc;
  226.      
  227.     FRAME_ADDR next_frame;
  228.      
  229.      
  230.     FRAME next, prev;
  231.   };
  232.  
  233. struct frame_saved_regs
  234.   {
  235.      
  236.     unsigned int  regs[16 ];
  237.   };
  238.  
  239. extern FRAME selected_frame;
  240. extern struct frame_info *get_frame_info ();
  241. extern struct frame_info *get_prev_frame_info ();
  242. extern FRAME create_new_frame ();
  243. extern void get_frame_saved_regs ();
  244. extern FRAME get_prev_frame ();
  245. extern FRAME get_current_frame ();
  246. extern FRAME get_next_frame ();
  247. extern struct block *get_frame_block ();
  248. extern struct block *get_current_block ();
  249. extern struct block *get_selected_block ();
  250. extern struct symbol *get_frame_function ();
  251. extern struct symbol *get_pc_function ();
  252.  
  253. extern FRAME find_relative_frame ();
  254.  
  255. # 23 "inflow.c" 2
  256. # 1 "dist/inferior.h" 1
  257.  
  258.  
  259. struct inferior_status {
  260.   int pc_changed;
  261.   int stop_signal;
  262.   int stop_pc;
  263.   int stop_frame_address;
  264.   int stop_breakpoint;
  265.   int stop_step;
  266.   int stop_stack_dummy;
  267.   int stopped_by_random_signal;
  268.   int trap_expected;
  269.   unsigned int  step_range_start;
  270.   unsigned int  step_range_end;
  271.   FRAME_ADDR step_frame_address;
  272.   int step_over_calls;
  273.   unsigned int  step_resume_break_address;
  274.   int stop_after_trap;
  275.   int stop_after_attach;
  276.   FRAME_ADDR selected_frame_address;
  277.   int selected_level;
  278.   struct command_line *breakpoint_commands;
  279.   char stop_registers[(16  * 4) ];
  280.   int restore_stack_info;
  281. };
  282. void save_inferior_status (), restore_inferior_status ();
  283.  
  284. extern char *inferior_io_terminal;
  285.  
  286. extern int inferior_pid;
  287.  
  288. extern int remote_debugging;
  289.  
  290. int remote_read_inferior_memory ();
  291. int remote_write_inferior_memory ();
  292.  
  293. extern int stop_signal;
  294.  
  295. extern unsigned int  stop_pc;
  296.  
  297. extern FRAME_ADDR stop_frame_address;
  298.  
  299. extern int stop_breakpoint;
  300.  
  301. extern int stop_step;
  302.  
  303. extern int stop_stack_dummy;
  304.  
  305. extern int stopped_by_random_signal;
  306.  
  307. extern unsigned int  step_range_start;  
  308. extern unsigned int  step_range_end;  
  309.  
  310. extern FRAME_ADDR step_frame_address;
  311.  
  312. extern int step_over_calls;
  313.  
  314. extern int step_multi;
  315.  
  316. extern char stop_registers[(16  * 4) ];
  317.  
  318. extern int pc_changed;
  319. long read_memory_integer ();
  320. # 24 "inflow.c" 2
  321. # 1 "/sprite/lib/include/sys/types.h" 1
  322.  
  323.  
  324.  
  325.  
  326.  
  327. typedef    unsigned char    u_char;
  328. typedef    unsigned short    u_short;
  329. typedef    unsigned int    u_int;
  330. typedef    unsigned long    u_long;
  331. typedef    unsigned short    ushort;         
  332. typedef    struct    _quad { long val[2]; } quad;
  333. typedef    long    daddr_t;
  334. typedef    char *    caddr_t;
  335. typedef    long *    qaddr_t;     
  336. typedef    u_long    ino_t;
  337. typedef    long    swblk_t;
  338. typedef    int    size_t;
  339. typedef    long    time_t;
  340. typedef    long    clock_t;
  341. typedef    short    dev_t;
  342. typedef    long    off_t;
  343. typedef    short    uid_t;
  344. typedef    short    gid_t;
  345. typedef long    key_t;         
  346.  
  347. typedef long    fd_mask;
  348. typedef    struct fd_set {
  349.     fd_mask    fds_bits[(((256 )+(( (sizeof(fd_mask) * 8        )    )-1))/( (sizeof(fd_mask) * 8        )    )) ];
  350. } fd_set;
  351. # 27 "inflow.c" 2
  352.  
  353. # 1 "/sprite/lib/include/fcntl.h" 1
  354.  
  355.  
  356.                      
  357.  
  358.  
  359. # 32 "inflow.c" 2
  360. # 1 "/sprite/lib/include/sys/param.h" 1
  361.  
  362. # 1 "/sprite/lib/include/sys/types.h" 1
  363.  
  364. # 99 "/sprite/lib/include/sys/types.h"
  365. # 26 "/sprite/lib/include/sys/param.h" 2
  366. # 1 "/sprite/lib/include/signal.h" 1
  367.  
  368.  
  369. void    (*signal())();
  370.  
  371. struct    sigvec {
  372.     void    (*sv_handler)();     
  373.     int    sv_mask;         
  374.     int    sv_flags;         
  375. };
  376.  
  377. struct    sigstack {
  378.     char    *ss_sp;             
  379.     int    ss_onstack;         
  380. };
  381.  
  382. struct    sigcontext {
  383.     int    sc_onstack;         
  384.     int    sc_mask;         
  385.     int    sc_sp;             
  386.     int    sc_fp;             
  387.     int    sc_ap;             
  388.     int    sc_pc;             
  389.     int    sc_ps;             
  390. };
  391.  
  392. # 27 "/sprite/lib/include/sys/param.h" 2
  393. # 1 "/sprite/lib/include/symm.md/machparam.h" 1
  394.  
  395. # 1 "/sprite/lib/include/symm.md/limits.h" 1
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407. # 38 "/sprite/lib/include/symm.md/machparam.h" 2
  408.  
  409.  
  410.  
  411.  
  412.  
  413. # 28 "/sprite/lib/include/sys/param.h" 2
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424. # 34 "inflow.c" 2
  425. # 1 "/sprite/lib/include/sys/dir.h" 1
  426.  
  427. # 1 "/sprite/lib/include/sys/types.h" 1
  428.  
  429. # 99 "/sprite/lib/include/sys/types.h"
  430. # 12 "/sprite/lib/include/sys/dir.h" 2
  431.  
  432.  
  433. struct    direct {
  434.     u_long    d_ino;             
  435.     u_short    d_reclen;         
  436.     u_short    d_namlen;         
  437.     char    d_name[255  + 1];     
  438. };
  439.  
  440.  
  441. typedef struct _dirdesc {
  442.     int    dd_fd;
  443.     long    dd_loc;
  444.     long    dd_size;
  445.     char    dd_buf[512  ];
  446. } DIR;
  447. extern    DIR *opendir();
  448. extern    struct direct *readdir();
  449. extern    long telldir();
  450. extern    void seekdir();
  451. extern    void closedir();
  452. # 35 "inflow.c" 2
  453. # 1 "/sprite/lib/include/signal.h" 1
  454.  
  455. # 114 "/sprite/lib/include/signal.h"
  456. # 36 "inflow.c" 2
  457. # 47 "inflow.c"
  458. # 1 "/sprite/lib/include/sys/ioctl.h" 1
  459.  
  460. # 1 "/sprite/lib/include/sys/ttychars.h" 1
  461.  
  462.  
  463. struct ttychars {
  464.     char    tc_erase;     
  465.     char    tc_kill;     
  466.     char    tc_intrc;     
  467.     char    tc_quitc;     
  468.     char    tc_startc;     
  469.     char    tc_stopc;     
  470.     char    tc_eofc;     
  471.     char    tc_brkc;     
  472.     char    tc_suspc;     
  473.     char    tc_dsuspc;     
  474.     char    tc_rprntc;     
  475.     char    tc_flushc;     
  476.     char    tc_werasc;     
  477.     char    tc_lnextc;     
  478. };
  479.  
  480. # 13 "/sprite/lib/include/sys/ioctl.h" 2
  481. # 1 "/sprite/lib/include/sys/ttydev.h" 1
  482.  
  483.  
  484.  
  485. # 16 "/sprite/lib/include/sys/ioctl.h" 2
  486. # 1 "/sprite/lib/include/sys/fb.h" 1
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493. typedef struct    fbtype {
  494.     int    fb_type;     
  495.     int    fb_height;     
  496.     int    fb_width;     
  497.     int    fb_depth;     
  498.     int    fb_cmsize;     
  499.     int    fb_size;     
  500. } fbtype;
  501.  
  502. typedef struct    fbinfo {
  503.     int        fb_physaddr;     
  504.     int        fb_hwwidth;     
  505.     int        fb_hwheight;     
  506.     int        fb_addrdelta;     
  507.     unsigned char    *fb_ropaddr;     
  508.     int        fb_unit;     
  509. } fbinfo;
  510.  
  511. typedef struct    fbcmap {
  512.     int        index;         
  513.     int        count;         
  514.     unsigned char    *red;         
  515.     unsigned char    *green;         
  516.     unsigned char    *blue;         
  517. } fbcmap;
  518. typedef struct fbsattr {
  519.     int    flags;             
  520.     int    emu_type;         
  521.     int    dev_specific[8    ];     
  522. } fbsattr;
  523. typedef struct fbgattr {
  524.     int    real_type;         
  525.     int    owner;             
  526.     struct    fbtype fbtype;         
  527.     struct    fbsattr sattr;         
  528.     int    emu_types[4    ];     
  529.                          
  530. } fbgattr;
  531. struct    fbpixrect {
  532.     struct pixrect    *fbpr_pixrect;     
  533. };
  534. # 20 "/sprite/lib/include/sys/ioctl.h" 2
  535.  
  536. struct tchars {
  537.     char    t_intrc;     
  538.     char    t_quitc;     
  539.     char    t_startc;     
  540.     char    t_stopc;     
  541.     char    t_eofc;         
  542.     char    t_brkc;         
  543. };
  544. struct ltchars {
  545.     char    t_suspc;     
  546.     char    t_dsuspc;     
  547.     char    t_rprntc;     
  548.     char    t_flushc;     
  549.     char    t_werasc;     
  550.     char    t_lnextc;     
  551. };
  552.  
  553. struct sgttyb {
  554.     char    sg_ispeed;         
  555.     char    sg_ospeed;         
  556.     char    sg_erase;         
  557.     char    sg_kill;         
  558.     short    sg_flags;         
  559. };
  560.  
  561. struct winsize {
  562.     unsigned short    ws_row;             
  563.     unsigned short    ws_col;             
  564.     unsigned short    ws_xpixel;         
  565.     unsigned short    ws_ypixel;         
  566. };
  567.  
  568. struct ttysize {
  569.     unsigned short    ts_lines;
  570.     unsigned short    ts_cols;
  571.     unsigned short    ts_xxx;
  572.     unsigned short    ts_yyy;
  573. };
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583. # 48 "inflow.c" 2
  584.  
  585. # 1 "/sprite/lib/include/sgtty.h" 1
  586.  
  587. # 50 "inflow.c" 2
  588. extern int errno;
  589.  
  590. int attach_flag;
  591.  
  592.  
  593. static struct sgttyb  sg_inferior;
  594. static struct sgttyb  sg_ours;
  595. static int tflags_inferior;
  596. static int tflags_ours;
  597. static struct tchars tc_inferior;
  598. static struct tchars tc_ours;
  599. static struct ltchars ltc_inferior;
  600. static struct ltchars ltc_ours;
  601. static int lmode_inferior;
  602. static int lmode_ours;
  603. static int pgrp_inferior;
  604. static int pgrp_ours;
  605.  
  606. static char *inferior_thisrun_terminal;
  607. static void terminal_ours_1 ();
  608.  
  609. static int terminal_is_ours;
  610.  
  611. void
  612. terminal_init_inferior ()
  613. {
  614.   if (remote_debugging)
  615.     return;
  616.   sg_inferior = sg_ours;
  617.   tflags_inferior = tflags_ours;
  618.   tc_inferior = tc_ours;
  619.   ltc_inferior = ltc_ours;
  620.   lmode_inferior = lmode_ours;
  621.   pgrp_inferior = inferior_pid;
  622.   terminal_is_ours = 1;
  623. }
  624.  
  625. void
  626. terminal_inferior ()
  627. {
  628.   if (remote_debugging)
  629.     return;
  630.   if (terminal_is_ours)    
  631.     {
  632.       fcntl (0, 4    , tflags_inferior);
  633.       fcntl (0, 4    , tflags_inferior);
  634.       ioctl (0, ((int) (    0x80000000    |((sizeof(struct sgttyb)&0x1fff        )<<16)|('t'<<8)|10))  , &sg_inferior);
  635.       ioctl (0, ((int) (    0x80000000    |((sizeof(struct tchars)&0x1fff        )<<16)|('t'<<8)|17))  , &tc_inferior);
  636.       ioctl (0, ((int) (    0x80000000    |((sizeof(struct ltchars)&0x1fff        )<<16)|('t'<<8)|117))  , <c_inferior);
  637.       ioctl (0, ((int) (    0x80000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 125))     , &lmode_inferior);
  638.       ioctl (0, ((int) (    0x80000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 118))     , &pgrp_inferior);
  639.     }
  640.   terminal_is_ours = 0;
  641. }
  642.  
  643. void
  644. terminal_ours_for_output ()
  645. {
  646.   if (remote_debugging)
  647.     return;
  648.   terminal_ours_1 (1);
  649. }
  650.  
  651. void
  652. terminal_ours ()
  653. {
  654.   if (remote_debugging)
  655.     return;
  656.   terminal_ours_1 (0);
  657. }
  658. static void
  659. terminal_ours_1 (output_only)
  660.      int output_only;
  661. {
  662.    
  663.   int (*osigttou) ();
  664.   if (!terminal_is_ours)   
  665.     {
  666.       terminal_is_ours = 1;
  667.       osigttou = (int (*) ()) signal (22    ,     (void (*)())1 );
  668.       ioctl (0, ((int) (    0x40000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 119))     , &pgrp_inferior);
  669.       ioctl (0, ((int) (    0x80000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 118))     , &pgrp_ours);
  670.       signal (22    , osigttou);
  671.       tflags_inferior = fcntl (0, 3    , 0);
  672.       ioctl (0, ((int) (    0x40000000    |((sizeof(struct sgttyb)&0x1fff        )<<16)|('t'<<8)| 8))  , &sg_inferior);
  673.       ioctl (0, ((int) (    0x40000000    |((sizeof(struct tchars)&0x1fff        )<<16)|('t'<<8)|18))  , &tc_inferior);
  674.       ioctl (0, ((int) (    0x40000000    |((sizeof(struct ltchars)&0x1fff        )<<16)|('t'<<8)|116))  , <c_inferior);
  675.       ioctl (0, ((int) (    0x40000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 124))     , &lmode_inferior);
  676.     }
  677.   sg_ours.sg_flags &= ~    0x00000020     & ~    0x00000002    ;
  678.   if (output_only)
  679.     sg_ours.sg_flags |= (    0x00000020     |     0x00000002    ) & sg_inferior.sg_flags;
  680.   fcntl (0, 4    , tflags_ours);
  681.   fcntl (0, 4    , tflags_ours);
  682.   ioctl (0, ((int) (    0x80000000    |((sizeof(struct sgttyb)&0x1fff        )<<16)|('t'<<8)|10))  , &sg_ours);
  683.   ioctl (0, ((int) (    0x80000000    |((sizeof(struct tchars)&0x1fff        )<<16)|('t'<<8)|17))  , &tc_ours);
  684.   ioctl (0, ((int) (    0x80000000    |((sizeof(struct ltchars)&0x1fff        )<<16)|('t'<<8)|117))  , <c_ours);
  685.   ioctl (0, ((int) (    0x80000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 125))     , &lmode_ours);
  686.   sg_ours.sg_flags &= ~    0x00000020     & ~    0x00000002    ;
  687. }
  688. static void
  689. term_status_command ()
  690. {
  691.   register int i;
  692.   if (remote_debugging)
  693.     {
  694.       printf_filtered ("No terminal status when remote debugging.\n");
  695.       return;
  696.     }
  697.   printf_filtered ("Inferior's terminal status (currently saved by GDB):\n");
  698. # 298 "inflow.c"
  699.   printf_filtered ("fcntl flags = 0x%x, sgttyb.sg_flags = 0x%x, owner pid = %d.\n",
  700.       tflags_inferior, sg_inferior.sg_flags, pgrp_inferior);
  701.   printf_filtered ("tchars: ");
  702.   for (i = 0; i < sizeof (struct tchars); i++)
  703.     printf_filtered ("0x%x ", ((char *)&tc_inferior)[i]);
  704.   printf_filtered ("\n");
  705.   printf_filtered ("ltchars: ");
  706.   for (i = 0; i < sizeof (struct ltchars); i++)
  707.     printf_filtered ("0x%x ", ((char *)<c_inferior)[i]);
  708.   printf_filtered ("\n");
  709.   ioctl (0, ((int) (    0x80000000    |((sizeof(struct ltchars)&0x1fff        )<<16)|('t'<<8)|117))  , <c_ours);
  710.   
  711.   printf_filtered ("lmode:  %x\n", lmode_inferior);
  712. }
  713.  
  714. static void
  715. new_tty (ttyname)
  716.      char *ttyname;
  717. {
  718.   register int tty;
  719.   register int fd;
  720.    
  721.   tty = open("/dev/tty",     002        );
  722.   if (tty > 0)
  723.     {
  724.       ioctl(tty, ((int) (0x20000000    |('t'<<8)| 113))         , 0);
  725.       close(tty);
  726.     }
  727.    
  728.   tty = open(ttyname,     002        );
  729.   if (tty == -1)
  730.     _exit(1);
  731.    
  732.   if (tty != 0)
  733.     { close (0); dup (tty); }
  734.   if (tty != 1)
  735.     { close (1); dup (tty); }
  736.   if (tty != 2)
  737.     { close (2); dup (tty); }
  738.   if (tty > 2)
  739.     close(tty);
  740. }
  741.  
  742.  
  743. int
  744. create_inferior (allargs, env)
  745.      char *allargs;
  746.      char **env;
  747. {
  748.   int pid;
  749.   char *shell_command;
  750.   extern int sys_nerr;
  751.   extern char *sys_errlist[];
  752.   extern int errno;
  753.    
  754.   shell_command = allargs;
  755.    
  756.   close_exec_file ();
  757.   pid = fork ();
  758.   if (pid < 0)
  759.     perror_with_name ("vfork");
  760.   if (pid == 0)
  761.     {
  762.        
  763.       setpgrp (getpid (), getpid ());
  764. # 420 "inflow.c"
  765.       inferior_thisrun_terminal = inferior_io_terminal;
  766.       if (inferior_io_terminal != 0)
  767.     new_tty (inferior_io_terminal);
  768.  
  769.  
  770.  
  771.        
  772.       signal (3    ,     (void (*)())0 );
  773.       signal (2    ,     (void (*)())0 );
  774.       call_ptrace (0);
  775.       execle ("/bin/sh" , "sh", "-c", shell_command, 0, env);
  776.       fprintf ((&stdioErrFile) , "Cannot exec %s: %s.\n", "/bin/sh" ,
  777.            errno < sys_nerr ? sys_errlist[errno] : "unknown error");
  778.       fflush ((&stdioErrFile) );
  779.       _exit (0177);
  780.     }
  781.   return pid;
  782. }
  783.  
  784. static void
  785. kill_command ()
  786. {
  787.   if (remote_debugging)
  788.     return;
  789.   if (inferior_pid == 0)
  790.     error ("The program is not being run.");
  791.   if (!query ("Kill the inferior process? "))
  792.     error ("Not confirmed.");
  793.   kill_inferior ();
  794. }
  795. void
  796. inferior_died ()
  797. {
  798.   inferior_pid = 0;
  799.   attach_flag = 0;
  800.   mark_breakpoints_out ();
  801.   select_frame ((FRAME) 0, -1);
  802.   reopen_exec_file ();
  803.   if (have_core_file_p ())
  804.     set_current_frame ( create_new_frame (read_register (5        ),
  805.                       read_pc ()));
  806.   else
  807.     set_current_frame (0);
  808. }
  809.  
  810. # 523 "inflow.c"
  811.  
  812. void
  813. _initialize_inflow ()
  814. {
  815.   add_com ("term-status", class_obscure, term_status_command,
  816.        "Print info on inferior's saved terminal status.");
  817.   add_com ("kill", class_run, kill_command,
  818.        "Kill execution of program being debugged.");
  819.   inferior_pid = 0;
  820.   ioctl (0, ((int) (    0x40000000    |((sizeof(struct sgttyb)&0x1fff        )<<16)|('t'<<8)| 8))  , &sg_ours);
  821.   fcntl (0, 3    , tflags_ours);
  822.   ioctl (0, ((int) (    0x40000000    |((sizeof(struct tchars)&0x1fff        )<<16)|('t'<<8)|18))  , &tc_ours);
  823.   ioctl (0, ((int) (    0x40000000    |((sizeof(struct ltchars)&0x1fff        )<<16)|('t'<<8)|116))  , <c_ours);
  824.   ioctl (0, ((int) (    0x40000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 124))     , &lmode_ours);
  825.   ioctl (0, ((int) (    0x40000000    |((sizeof( int)&0x1fff        )<<16)|('t'<<8)| 119))     , &pgrp_ours);
  826.   terminal_is_ours = 1;
  827. }
  828.